package com.fengye.algorithms.leecode;

/**
 * @Author fengye
 * @Date 2023/4/10 9:16
 **/
public class CanConstruct383 {
    public boolean canConstruct(String ransomNote, String magazine) {
        StringBuilder sb = new StringBuilder(ransomNote);
        for(int i = 0; i < magazine.length();i++) {
            char ch = magazine.charAt(i);
            if(ransomNote.contains(Character.toString(ch))) {
                int inx = ransomNote.indexOf(ch);
                sb.deleteCharAt(inx);
                ransomNote = sb.toString();
            }
        }

        if(sb.length() == 0) {
            return true;
        }
        return false;
    }
}
